# -*- coding: utf-8 -*-
import unittest

from case.UserTestInfo_test import UserTestInfo
from util.requests_handler import RequestsHandler
from util.RequestsUtil import RequestUtil

host = "https://api.xdclass.net"
class IndexTestLogin(unittest.TestCase):

    def testLogin(self):
        """登录"""
        req =RequestUtil()
        url = 'https://api.xdclass.net/pub/api/v1/web/web_login'

        headers = {"Content-Type": "application/x-www-form-urlencoded"}
        data = {"phone":"13113777555","pwd":"1234567890"}
        method ='post'

        result = req.requesthandler(url=url,method=method,param=data,headers=headers)
        b = result['data']['token']
        print(result['data']['token'])


        self.assertEqual(result['code'],0,"业务不正常")
        """
        #方式一：通过参数传入token
        userTestInfo = UserTestInfo()
        userTestInfo.test_get_info1(result['data']['token'])

        print('----------------------------------------')


        #方式二：这个暂时就先这样吧
        requestHandler = RequestsHandler()
        result1 = requestHandler.visit(url=url,method = method,params=data,headers=headers)
        print(result1)
        print(result1['data']['token'])
        requestHandler.session.params.setdefault('token',result1['data']['token'])
        print(requestHandler.session.params.get('token'))
        
        """

if __name__ == '__main__':
    unittest.main(verbosity=2)

